package com.tompai.echarts.logger.aspect;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 
 * @site WebLogTestController
 * @date 2021/2/12
 * @time 下午9:19
 * @discription
 **/
@RestController
public class WebLogTestController {

	private final static Logger logger = LoggerFactory.getLogger(WebLogTestController.class);

	/**
	 * POST 方式接口测试
	 * @param user
	 * @return
	 */
	@PostMapping("/user/login")
	@WebLog(description = "请求了用户登录接口")
	public User userLogin(@RequestBody User user) {
		logger.info("user login ...");
		return user;
	}

	/**
	 * GET 方式接口测试
	 * @return
	 */
	@GetMapping("/user/{id}")
	@WebLog(description = "请求了用户登录接口")
	public String findUserInfo(@PathVariable("id") String userId) {
		logger.info("find user info ...");
		return "success";
	}

	/**
	 * GET 方式接口测试
	 * @return
	 */
	@GetMapping("/test")
	@WebLog(description = "test-请求了用户登录接口")
	public String test() {
		logger.info("testGet ...");
		return "success";
	}

	/**
	 * 单文件上传接口测试
	 * @return
	 */
	@PostMapping("/file/upload")
	@WebLog(description = "@PostMapping-请求了用户登录接口")
	public String testFileUpload(@RequestParam("file") MultipartFile file) {
		logger.info("testFileUpload ...");
		return "success";
	}

	/**
	 * 多文件上传接口测试
	 * @return
	 */
	@PostMapping("/multiFile/upload")
	@WebLog(description = "@PostMultiFile-请求了用户登录接口")
	public String testMultiFileUpload(@RequestParam("file") MultipartFile[] file) {
		logger.info("testMultiFileUpload ...");
		return "success";
	}
}
